<template>
	<div id="finance_profit">
		
		<el-table :data="list" stripe style="width: 100%" v-loading="load">
			<el-table-column prop="id" label="id" align="center"></el-table-column>
			<el-table-column label="收益金额" width="140" align="center">
				<template slot-scope="scope">
					<span>{{$common.toThousands(scope.row.money, true)}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="origin" label="收益来源" align="center"></el-table-column>
			<el-table-column prop="remark" label="备注" align="center"></el-table-column>
			<el-table-column label="创建时间" align="center">
				<template slot-scope="scope">
					<span>{{$moment(scope.row.createTime).format('Y-MM-DD HH:mm')}}</span>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination
			background
			layout="total, prev, pager, next"
			:page-size="requestParam.pageSize"
			:total="total"
		 	@current-change="getList"
			 class="margin_top20 align-right">
		</el-pagination>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				requestParam: {
					startTime: '',
					endTime: '',
					pageSize: 10,
					pageNo: 1
				},
				total: 0,
				load: false,
				date: [],
			};
		},

		created() {
			this.search()
		},

		methods: {
			// 获取列表
			getList(pageNo) {
				if (this.load) {
					return;
				}
				if (this.date && this.date.length) {
					this.requestParam.startTime = this.$moment(this.date[0]).format('Y-MM-DD HH:mm:ss')
					this.requestParam.endTime = this.$moment(this.date[1]).format('Y-MM-DD HH:mm:ss')
				} else {
					this.date = [];
					this.requestParam.startTime = ''
					this.requestParam.endTime = ''
				}
				this.load = true
				this.requestParam.pageNo = pageNo
				this.$request.post({
					url: '/ReportApi/admin/financeunprofitlist',
					params: this.requestParam,
					success: result => {
						this.list = result[0]
						if (this.requestParam.isCount) {
							this.total = result[1]
						}
					},
					finally: () => {
						this.load = false
					}
				})
			},

			search() {
				this.requestParam.isCount = true
				this.getList(1)
			}
		}
	}
</script>

<style>
</style>
